<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>Anson&#39;s Blog | 种一棵树最好的时间在十年前，其次是现在。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="">
    <meta name="description" content="张宁乐,博客">
<meta property="og:type" content="website">
<meta property="og:title" content="Anson&#39;s Blog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Anson&#39;s Blog">
<meta property="og:description" content="张宁乐,博客">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Anson&#39;s Blog">
<meta name="twitter:description" content="张宁乐,博客">
    
        <link rel="alternate" type="application/atom+xml" title="Anson&#39;s Blog" href="/atom.xml">
    
    <link rel="shortcut icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu"  >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="https://yscoder.github.io/img/face.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">张宁乐</h5>
          <a href="mailto:zhangningle2017@gmail.com" title="zhangningle2017@gmail.com" class="mail">zhangningle2017@gmail.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect active">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/about"  >
                <i class="icon icon-lg icon-user"></i>
                关于
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/ansonznl" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">Anson&#39;s Blog</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header index-header">

    <div class="container fade-scale">
        <h1 class="title">Anson&#39;s Blog</h1>
        <h5 class="subtitle">
            
                种一棵树最好的时间在十年前，其次是现在。
            
        </h5>
    </div>

    


</header>

<div class="container body-wrap">

    <ul class="post-list">
    
        <li class="post-list-item fade">
            <article id="post-使用Promise封装小程序wx.request"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-11-30 16:20:14" datetime="2019-11-30T08:20:14.000Z"  itemprop="datePublished">
2019-11-30
<!--2019-11-30 16:34:10-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/11/30/使用Promise封装小程序wx.request/">使用Promise封装小程序wx.request</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        因为业务需要，每个http请求都要加上一个请求头，所以每次都要写很多重复的代码。
现在尝试把wx.request简单的封装了一下，调用一个request方法，每次请求自动携带header头信息，这样就省事多了，包含了常见的get post put delete 四种请求方法，支持Promise方式调用。
封装代码1234567891011121314151617181920212223242...
    

        <a href="/2019/11/30/使用Promise封装小程序wx.request/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/小程序/">小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-在小程序中自定义弹窗组件"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-11-30 16:20:14" datetime="2019-11-30T08:20:14.000Z"  itemprop="datePublished">
2019-11-30
<!--2019-11-30 16:32:58-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/11/30/在小程序中自定义弹窗组件/">在小程序中调用API在小程序中自定义弹窗组件</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        因为业务需要在小程序里加上很多的弹窗，就想写一个组件来实现；
创建组件
新建文件夹component专门放组件，
新建popup页面，在popup.json中设置：123&#123;    &quot;component&quot;: true&#125;


表明它是一个组件，我们称之为“子组件”

注意：在组件wxss中不应使用ID选择器、属性选择器和标签名选择器。（只使用class）如...
    

        <a href="/2019/11/30/在小程序中自定义弹窗组件/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/小程序/">小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-清除小程序button的默认样式"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-11-30 16:20:14" datetime="2019-11-30T08:20:14.000Z"  itemprop="datePublished">
2019-11-30
<!--2019-11-30 16:33:39-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/11/30/清除小程序button的默认样式/">清除小程序button的默认样式</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        彻底清除小程序按钮的默认样式wxml：1&lt;button hover-class=&quot;none&quot;&gt;&lt;/button&gt;
wxss：123456789101112button&#123;  line-height: 1;  margin:0;&#125;button::after&#123;  border:none;&#125;input&#123;  ...
    

        <a href="/2019/11/30/清除小程序button的默认样式/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/小程序/">小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-小程序之瀑布流布局"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-09-27 15:39:03" datetime="2019-09-27T07:39:03.000Z"  itemprop="datePublished">
2019-09-27
<!--2019-09-27 16:51:20-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/09/27/小程序之瀑布流布局/">小程序-两列瀑布流布局</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        新的设计图是按两列瀑布流排版的，类似于花瓣网那种。看到设计图后就在网上找，如何在小程序简单的实现，后来找到了一个特别简单的方法，就是利用wx:if和数组的下标对2取余来判断是排在左列还是排在右列，话不多说看图上代码：
                
                    
                    
                
            ...
    

        <a href="/2019/09/27/小程序之瀑布流布局/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/微信小程序/">微信小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-小程序-实现蒙版弹出窗"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-09-17 10:39:03" datetime="2019-09-17T02:39:03.000Z"  itemprop="datePublished">
2019-09-17
<!--2019-09-17 11:40:46-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/09/17/小程序-实现蒙版弹出窗/">小程序-蒙版弹出窗</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        
                
                    
                    
                
                蒙版弹出窗.gif
            
话不多说 上代码。wxml:123456789101112&lt;view class=&quot;page&quot;&gt;  &lt;button bind...
    

        <a href="/2019/09/17/小程序-实现蒙版弹出窗/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/微信小程序/">微信小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-小程序中图片点击全屏-可滑动"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-08-27 15:21:55" datetime="2019-08-27T07:21:55.000Z"  itemprop="datePublished">
2019-08-27
<!--2019-08-27 15:32:27-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/08/27/小程序中图片点击全屏-可滑动/">小程序中图片点击全屏-可滑动</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        在小程序中，如果页面中有多张图片，那么用户可能会习惯向在朋友圈中一样打开图片，这里微信也提供了类似的api，可以直接拿来实现这个效果。

                
                    
                    
                
                小程序图片点击全屏.gif
            
wxml:1234...
    

        <a href="/2019/08/27/小程序中图片点击全屏-可滑动/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/微信小程序/">微信小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-小程序之iPhone x适配"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-08-27 15:21:55" datetime="2019-08-27T07:21:55.000Z"  itemprop="datePublished">
2019-08-27
<!--2019-08-27 15:34:04-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/08/27/小程序之iPhone x适配/">小程序之iPhone x适配</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        参考小程序iPhone X 视适配
在开发小程序时，可能需要适配iPhone x 的时候，你会发现底部的横线会出现遮挡，这时候就要处理下：
在app.js中添加一个检测当前设备是否是iPhoneX的变量：12345678910111213141516globalData: &#123;  userInfo: null,  isIphoneX: false//判断是否是iPhoneX&#125...
    

        <a href="/2019/08/27/小程序之iPhone x适配/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/微信小程序/">微信小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-小程序速查"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-08-16 14:49:03" datetime="2019-08-16T06:49:03.000Z"  itemprop="datePublished">
2019-08-16
<!--2019-08-27 15:49:13-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/08/16/小程序速查/">小程序速记[基础]</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        小程序基础JSON
project.config.json: 项目配置文件 app.json: 全局配置文件 page.json: 项目配置文件
app.json 配置相对应页面的路由（全局配置），window窗口配置：，各页面配置：，tab标签配置
每个页面对应的page.json 也可以配置window 信息，如与app.json相同则覆盖app.json配置

WXML
模板语法 在w...
    

        <a href="/2019/08/16/小程序速查/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/微信小程序/">微信小程序</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-深浅拷贝"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-06-26 10:04:55" datetime="2019-06-26T02:04:55.000Z"  itemprop="datePublished">
2019-06-26
<!--2019-06-26 10:30:08-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/06/26/深浅拷贝/">深浅拷贝</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        为什么要进行拷贝123456var obj1=&#123;    value: &apos;a&apos;&#125;var obj2 = obj1;obj2.value=&apos;b&apos;;console.log(obj1);//&#123; value: &apos;b&apos; &#125;
 因为对象是引用类型，所以赋值时的操作仅是赋予相同的地址，当对其中一个对象进行操作时...
    

        <a href="/2019/06/26/深浅拷贝/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/">JavaScript</a></li></ul>

    </div>
    
</article>

        </li>
    
        <li class="post-list-item fade">
            <article id="post-创建对象的几种方法及优缺点"
  class="article-card article-type-post" itemprop="blogPost">

    <div class="post-meta">
        <time class="post-time" title="2019-06-04 10:04:55" datetime="2019-06-04T02:04:55.000Z"  itemprop="datePublished">
2019-06-04
<!--2019-06-05 09:45:39-->
</time>

        


    </div>

    


  
    <h3 class="post-title" itemprop="name">
      <a class="post-title-link" href="/2019/06/04/创建对象的几种方法及优缺点/">创建对象的几种方法及优缺点</a>
    </h3>
  




    <div class="post-content" id="post-content" itemprop="postContent">

    
        new Object()直接通过构造函数创建一个新对象。12var obj = new Object()//等同于 var obj = &#123;&#125;
使用字面量的方式更简单，其实他俩是一样的。优点是足够简单，缺点是每个对象都是独立的。
工厂模式123456789function createObj(name,age)&#123;    var obj = &#123;&#125;...
    

        <a href="/2019/06/04/创建对象的几种方法及优缺点/" class="post-more waves-effect waves-button">
            阅读全文…
        </a>
    </div>
    
    <div class="post-footer">
        
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/">JavaScript</a></li></ul>

    </div>
    
</article>

        </li>
    
    </ul>

    
<nav id="page-nav">
    <div class="inner">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="extend next" rel="next" href="/page/2/">下一页</a>
    </div>
</nav>


</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>张宁乐 &copy; 2017 - 2019</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
			<span>
					Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a>
			  </span>
        </p>
    </div>
</footer>
<!-- <script>
(function(){
    var bp = document.createElement("script");
    var curProtocol = window.location.protocol.split(":")[0];
    if (curProtocol === "https") {
        bp.src = "https://zz.bdstatic.com/linksubmit/push.js";
    }
    else {
        bp.src = "http://push.zhanzhang.baidu.com/push.js";
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script> -->

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/&title=Anson's Blog&pic=https://yscoder.github.io/img/face.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/&title=Anson's Blog&source=张宁乐,博客" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=Anson's Blog&url=http://yoursite.com/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: false };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
